{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# yaml文件介绍\n",
    "\n",
    "yaml是一个专门用来写配置文件的语言。\n",
    "\n",
    "## yaml文件规则\n",
    "\n",
    "- 区分大小写；\n",
    "- 使用缩进表示层级关系；\n",
    "- **使用空格键缩进，而非Tab键缩进**\n",
    "- 缩进的空格数目不固定，只需要相同层级的元素左侧对齐；\n",
    "- 文件中的字符串不需要使用引号标注，但若字符串包含有特殊字符则需用引号标注；\n",
    "- 注释标识为#\n",
    "\n",
    "- 对象：键值对的集合（简称 \"映射或字典\"）\n",
    "- 映射: 用冒号(:)分隔key, value. 如果写在一行, 需要用逗号分隔并前后加花括号\n",
    "- 数组：一组按序排列的值（简称 \"序列或列表\"）\n",
    "- 数组前加有 “-” 符号，符号与值之间需用空格分隔\n",
    "- 纯量(scalars)：单个的、不可再分的值（如：字符串、bool值、整数、浮点数、时间、日期、null等）\n",
    "- None值可用null可 ~ 表示\n",
    "- 重复的节点, 可以用 & 标识, 并用 * 来引用\n",
    "- 字符串: 不加引号, 加单引号或者加双引号都可以, 加双引号时可以使用\\开头的转义字符\n",
    "- 多行字符串可以用 | 或 > 符号, 紧接着换行符\n",
    "\n",
    "\n",
    "# python中读取yaml配置文件\n",
    "\n",
    "## 前提条件\n",
    "\n",
    "python中读取yaml文件前需要安装pyyaml和导入yaml模块：\n",
    "\n",
    "```sh\n",
    "pip3 install pyyaml\n",
    "```\n",
    "\n",
    "导入的模块为\n",
    "\n",
    "```py\n",
    "import yaml\n",
    "```\n",
    "\n",
    "## 读取yaml文件数据\n",
    "\n",
    "python通过open方式读取文件数据，再通过load函数将数据转化为列表或字典；\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
